#include <bits/stdc++.h>
#define File(xxx) freopen(xxx".in","r",stdin),freopen(xxx".out","w",stdout)
using namespace std;
typedef long long LL;
// bool st;
const int N= 5e5+5, V = 1e6+5;
int n, u, v, cnt, lm[N], rm[N], mxl[V], mnr[V], tot[2], sum, ans[N];
struct bak {
	int w, d;
}ll[V], rr[V];
vector <int> add[N<<2], tp[N];
unordered_map <LL, int> qwq;
char s;

template <typename T> inline void debug(T x) { cerr<<x; }
template <typename T, typename ...T_> inline void debug(T x, T_ ...p) { cerr<<x<<' ', debug(p...); }
namespace FastIO {
	const int SIZE=(1<<21)+1;
	char ibuf[SIZE],obuf[SIZE],*iS,*iT,*oS=obuf,*oT=obuf;
	char* flush(){fwrite(obuf,1,oT-oS,stdout);return oT=obuf;}
	struct Flusher{~Flusher(){flush();}}flusher;
	inline char gc(){return iS==iT && (iT=(iS=ibuf)+fread(ibuf,1,SIZE,stdin),iS==iT)?EOF:*iS++;}
	inline void pc(char c){if(oT==oS+SIZE) flush();*oT++=c;}
	#define getchar gc
	#define putchar pc
	template <typename T> void read(T& x) {
		x = 0; int f = 0; char c = getchar();
		while(c < '0' || c > '9') f |= (c == '-'), c=getchar();
		while(c >= '0' && c <= '9') x=(x<<1)+(x<<3)+(c^48), c=getchar();
		x=(f ? -x : x);
	}
	int lne; char put[105];
	template <typename T> void write(T x, char ch) {
		lne = 0; if(x < 0) putchar('-'), x=-x;
		do { put[++lne]=x%10, x/=10; } while(x);
		while(lne) putchar(put[lne--]^48);
		putchar(ch);
	}
}
using FastIO::gc;
using FastIO::pc;
using FastIO::read;
using FastIO::write;
struct node { int ls, rs, w; };
struct tree {
	int gs, tr[V];
	bak rt[V*21];
	inline void add(int x, int w) {
		while(x)
			rt[++gs]=bak {x, tr[x]}, tr[x]=min(tr[x], w), x-=(x&(-x));
	}
	int ask(int x, int ret = 2000007) {
		while(x <= 1000000)
			ret=min(ret, tr[x]), x+=(x&(-x));
		return ret;
	}
	inline void cler(int to) {
		while(gs > to) tr[rt[gs].w]=rt[gs].d, --gs;
	}
}A;
struct treee {
	int gs, tr[V];
	bak rt[V*21];
	inline void add(int x, int w) {
		while(x <= 1000000)
			rt[++gs]=bak {x, tr[x]}, tr[x]=max(tr[x], w), x+=(x&(-x));
	}
	int ask(int x, int ret = -2000007) {
		while(x)
			ret=max(ret, tr[x]), x-=(x&(-x));
		return ret;
	}
	inline void cler(int to) {
		while(gs > to) tr[rt[gs].w]=rt[gs].d, --gs;
	}
}B;
#define ls (k<<1)
#define rs (ls|1)
void addd(int k, int l, int r, int lq, int rq, int op) {
	if(lq <= l && r <= rq) {
		add[k].push_back(op);
		return ;
	}
	int mid = ((l+r)>>1);
	if(lq <= mid)
		addd(ls, l, mid, lq, rq, op);
	if(mid < rq)
		addd(rs, mid+1, r, lq, rq, op);
}
void dfs(int k, int l, int r) {
	// debug(add[k].size(), k, l, r, "!!!\n");
	for(int op : add[k]) {
		// debug(op, "???\n");
		if(rm[op] < mnr[lm[op]])
			ll[++tot[0]]=bak {lm[op], mnr[lm[op]]}, mnr[lm[op]]=rm[op];
		if(lm[op] > mxl[rm[op]])
			rr[++tot[1]]=bak {rm[op], mxl[rm[op]]}, mxl[rm[op]]=lm[op];
		sum=min(sum, A.ask(rm[op]+1)-lm[op]+1);
		sum=min(sum, rm[op]-B.ask(lm[op]-1)+1);
		A.add(lm[op], rm[op]);
		B.add(rm[op], lm[op]);
		u=max(u, lm[op]);
		v=min(v, rm[op]);
	}
	if(l == r) {
		// debug(u, v, "???\n");
		if(u > v) 
			ans[l]=sum;
		else
			ans[l]=mnr[u]-mxl[v]+1;
		return ;
	}
	int mid = ((l+r)>>1), bku = u, bkv = v, cnt0 = tot[0], cnt1 = tot[1], summ = sum,
	gs = A.gs, gss = B.gs;
	dfs(ls, l, mid);
	u=bku, v=bkv;
	sum=summ;
	A.cler(gs), B.cler(gss);
	while(tot[0] > cnt0)
		mnr[ll[tot[0]].w]=ll[tot[0]].d, --tot[0];
	while(tot[1] > cnt1)
		mxl[rr[tot[1]].w]=rr[tot[1]].d, --tot[1];
	dfs(rs, mid+1, r);
	u=bku, v=bkv;
	sum=summ;
	A.cler(gs), B.cler(gss);
	while(tot[0] > cnt0)
		mnr[ll[tot[0]].w]=ll[tot[0]].d, --tot[0];
	while(tot[1] > cnt1)
		mxl[rr[tot[1]].w]=rr[tot[1]].d, --tot[1];
}
#undef ls
#undef rs
// bool fn;
signed main() {
	File("stone");
	// debug(-1.0*(&st-&fn)/1024/1024,"MB!\n");
	read(n);
	for(int i = 1; i <= n; ++i) {
		s=getchar();
		while(s != 'A' && s != 'R') s=getchar();
		read(u), read(v);
		if(qwq.find(1000000LL*u+v) == qwq.end())
			++cnt, lm[cnt]=u, rm[cnt]=v-1, qwq[1000000LL*u+v]=cnt;
		int nb = qwq[1000000LL*u+v];
		if(s == 'A') 
			tp[nb].push_back(i);
		else {
			addd(1, 1, n, tp[nb].back(), i-1, nb);
			tp[nb].pop_back();
		}
	}
	for(int i = 1; i <= cnt; ++i)
		while(!tp[i].empty())
			addd(1, 1, n, tp[i].back(), n, i), tp[i].pop_back();
	for(int i = 1; i <= 1000000; ++i)
		mnr[i]=A.tr[i]=2000007, mxl[i]=B.tr[i]=-2000007;
	u=1, v=1000000;
	sum=2000000;
	dfs(1, 1, n);
	for(int i = 1; i <= n; ++i)
		write(ans[i], '\n');
	FastIO::flusher.~Flusher();
	return 0;
}
